<template>
    <div class="body_inner">
  
  <div class="login_page">
    <div class="top">
      <h3>Daily Reward <br>Program</h3>
      <img src="../assets/img/icon/logo.png" alt="">
    </div>

    <div class="bottom">
      <form action="" class="form_boundary">
        <div>
          <p>아이디</p>
          <input type="text" v-model="idcard">
        </div>

        <div>
          <p>비밀번호</p>
          <input type="password" v-model="password">
        </div>

        <div class="btn" @click="login()">로그인</div>
      </form>

      <div class="link">
        <a href="/join"><i class="xi-user-plus-o"></i>회원가입</a>
        <a href="/password"><i class="xi-lock-o"></i>비밀번호 찾기</a>
      </div>
    </div>
  </div>
  
</div>
</template>
<script>
	import axios from "axios";
export default {
  data() {
    return {
		idcard:"",
		password:''
    };
  },
  created() {
  },
  methods: {
	  login(){
		  var _this = this;
		  if(!_this.idcard || !_this.password){
			  alert('전체 정보를 입력하십시오.');
			  return;
		  }
		  axios.post('https://admintest.pdt-daily.com/api/login/login', {
		    user_no:_this.idcard,
		    password:_this.password
		  }).then(function (response) {
		    console.log(response);
			if(response.data.status == 200){
				localStorage.setItem('token', response.data.data.token);
				// localStorage.getItem('token');
				_this.$router.push('/main')
			}
			if(response.data.status == 400){
				alert('계정 정보가 잘못되었습니다.')
			}
		  }).catch(function (error) {
		    console.log(error);
		  });
	  },
  },
};
</script>